package com.zara.store.common;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.basic.DateConverter;

public class PalcHelper {

	public String createXmlFromVO(PalcVO palcVO) {
		XStream xstream = createXstream();
		return xstream.toXML(palcVO);
	}

	public void createStreamFromVO(PalcVO palcVO, OutputStream os) {
		XStream xstream = createXstream();
		xstream.toXML(palcVO, os);
	}

	private XStream createXstream() {
		XStream xstream = new XStream();
	
		xstream.addDefaultImplementation(ArrayList.class, Collection.class);
		// xstream.addDefaultImplementation(java.sql.Date.class, java.sql.Date.class);
		// xstream.addDefaultImplementation(java.sql.Date.class, java.sql.Timestamp.class);
		xstream.registerConverter(new DateConverter("yyyy-MM-dd HH:mm:ss.SSS", new String[] { }));
				
		xstream.alias("palc", PalcVO.class);
		xstream.alias("product", PalcItemVO.class);
		return xstream;
	}

}
